rm(list = ls())
library(tidyverse)
library(haven)
library(coefplot)
library(tidyverse)
library(estimatr)
library(margins)
library(ggrepel)
library(cowplot)
dat <- read_dta("mobilization_bailard_gross_porter/data/main_recoded.dta")

dat$FactChecks <- dat$factchecks
dat$College <- dat$college4yrdegreeorabove
dat$Age <- dat$age5cat
dat$Male <- dat$male
dat$PartyID <- dat$pid7recoded
dat$Ideology <- dat$ideo5recoded
dat$NonWhite <- dat$nonwhite
dat$MediaIndex <- dat$mediaindex
dat$Battleground <- dat$battlegroundstates


model.1 <-lm(electionconfidenceindex ~ FactChecks, data=dat)
model.2 <-lm(electionconfidenceindex ~ Battleground + College + Age +
             Male + PartyID + Ideology + NonWhite  + MediaIndex + FactChecks, data=dat)

panel.1 <- coefplot(model.1, title="Fact-Checks and Election Confidence \n (No Covariates)",
                    intercept=FALSE)
panel.2 <- coefplot(model.2, title="Fact-Checks and Election Confidence \n (With Covariates)", intercept=FALSE)

plot_grid(panel.1, panel.2)
